package com.zhr.tea.view.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.zhr.tea.R;
import com.zhr.tea.entity.shouye.Chaquan;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by ym on 2016/11/6.
 */

public class ShouyeChaquanRemenAdapter extends RecyclerView.Adapter<ShouyeChaquanRemenAdapter.RemenViewHolder> {
    private List<Chaquan.ShareListBean> data;
    private Context context;

    public ShouyeChaquanRemenAdapter(Context context, List<Chaquan.ShareListBean> data) {
        this.context = context;
        this.data = data;
    }

    @Override
    public RemenViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(context).inflate(R.layout.item_chaquan_remen, null);
        RemenViewHolder holder = new RemenViewHolder(view);
        return holder;
    }

    @Override
    public void onBindViewHolder(RemenViewHolder holder, int position) {
        Glide.with(context).load(data.get(position).getSharePeoplePicUrl()).into(holder.ivSharepeople);
        Glide.with(context).load(data.get(position).getCoverUrl()).placeholder(R.mipmap.diy_bg).into(holder.ivCoverurl);
        holder.tvSharepeoplename.setText(data.get(position).getSharePeopleName());
        holder.tvSharetime.setText(data.get(position).getShareTime().substring(data.get(position).getShareTime().indexOf("-")+1));
        holder.tvSharetext.setText(data.get(position).getShareText());
        holder.tvRewardnum.setText("共领赏"+data.get(position).getRewardNum()+"茶币");
    }


    @Override
    public int getItemCount() {
        return data.size();
    }

    public class RemenViewHolder extends RecyclerView.ViewHolder {
        @BindView(R.id.iv_sharepeople)
        ImageView ivSharepeople;
        @BindView(R.id.tv_sharepeoplename)
        TextView tvSharepeoplename;
        @BindView(R.id.tv_sharetime)
        TextView tvSharetime;
        @BindView(R.id.tv_guanzhu)
        TextView tvGuanzhu;
        @BindView(R.id.tv_sharetext)
        TextView tvSharetext;
        @BindView(R.id.iv_coverurl)
        ImageView ivCoverurl;
        @BindView(R.id.tv_rewardnum)
        TextView tvRewardnum;

        public RemenViewHolder(View itemView) {
            super(itemView);
            ButterKnife.bind(this, itemView);
        }
    }


}
